package com.jeesite.modules.message.web;

import com.jeesite.common.config.Global;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.car.entity.Car;
import com.jeesite.modules.car.service.CarService;
import com.jeesite.modules.merchant.entity.Merchant;
import com.jeesite.modules.merchant.service.MerchantService;
import com.jeesite.modules.message.entity.Message;
import com.jeesite.modules.message.service.MessageService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "${adminPath}/message/message")
public class MessageController extends BaseController {

    @Autowired
    private MessageService messageService;
    @Autowired
    private CarService carService;
    @Autowired
    private MerchantService merchantService;

    @RequestMapping(value = "goMessageList")
    public String goMessageList() {
        return "modules/message/messageList";
    }
    @RequestMapping(value = "findMessageCount")
    @ResponseBody
    public String findMessageCount(Message message) {
        Map map = new HashMap<>();
        // 查询商户还有多少未审核
        Merchant merchant = new Merchant();
        merchant.setReviewStatus("0");
        long merchantCount = merchantService.findCount(merchant);
        map.put("merchantCount",merchantCount);
        // 查询车辆还有多少未审核
        Car car = new Car();
        car.setCarStatus("3");
        long carCount = carService.findCount(car);
        map.put("carCount",carCount);
        map.put("allCount",merchantCount + carCount);
        return renderResult(Global.TRUE, text("获取数据成功"),map );
    }
}
